function get(doubleLinkedList, position) {
  if (position < 0 || position > doubleLinkedList.length - 1) {
    return null;
  }

  let current = null,
    index = 0;
  // 如果在链表的后半截
  if (position > doubleLinkedList.length / 2) {
    // 从尾开始遍历
    current = this.tail;
    while (index < this.length) {
      current = current.next;
      index++;
    }
    return current.data;
  } else {
    //   如果在链表的前半截
    // 从头开始遍历
    current = this.head;
    while (index < position) {
      current = current.next;
      index++;
    }
    return current.data;
  }
}

function _call(context = window) {
  context.fn = this;

  const res = context.fn([...arguments].slice(1));

  delete context.fn;

  return res;
}

function _apply(context) {
  context = context || window;

  const res = context.fn([...arguments]);
  delete context.fn;
  return res;
}
